
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.ArrayList,
                 com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.commons.Constants"%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/addNewSalesRep.do"/>

<html:html locale="true">

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>

<script language='javascript'>
function save()
{
    var errorMsg="";
    <% if( Constants.CLIENT_NAME_AIRGO.equalsIgnoreCase( ConfigManager.getClientNameAirgo() )   ) { %>
        errorMsg = 'Please enter Airgo Representative name';
    <% }else{ %>
        errorMsg = 'Please enter Cavium Representative name';
    <%}%>

    var errors = '';
    var salesrep = document.addNewSalesRepForm.newSalesRep.value;
     if( salesrep.value != '')
    {
            if( salesrep.trim().length == 0)
            {
                errors = errors + "<li>"+ errorMsg;
                document.addNewSalesRepForm.newSalesRep.focus();
            }

    }
    //added by varma 28 jul 2004 to restrict double quote in Sales Rep name
    if( salesrep.indexOf('"') >= 0 )
    {
        var errorMessage="";
        <% if( Constants.CLIENT_NAME_AIRGO.equalsIgnoreCase( ConfigManager.getClientNameAirgo() )   ) { %>
            errorMsg = 'Please enter a valid Airgo Representative name';
        <% }else{ %>
            errorMsg = 'Please enter a valid Cavium Representative name';
        <%}%>
          errors = errors + "<li>"+ errorMessage;
          document.addNewSalesRepForm.newSalesRep.select();
          document.addNewSalesRepForm.newSalesRep.focus();

    }

    if(errors != '')
    {
        var inf = document.getElementById("infoMessagesId");
        inf.innerHTML = '';
        var err = document.getElementById("errorMessagesId");
        err.innerHTML = '';

        var pa=document.getElementById("errors");
        pa.innerHTML = errors;
        return;
    }

   var customerId = window.opener.document.customerForm['customer.customerId'].value;
   //alert(customerId);
   document.addNewSalesRepForm.action = '<%=chipTracContext%>/addNewSalesRep.do?action=insertSalesRep&customerId=' + customerId;

    document.addNewSalesRepForm.submit();
}
function reset(){
    document.addNewSalesRepForm.reset();
}

function closeWindow(form) {
    window.opener.document.customerForm['customer.customerNumber'].disabled=false;
    window.opener.document.customerForm.submit();
 	window.close();
}

</script>

<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<!-- from here your body starts -->

<html:form name="addNewSalesRepForm" type="com.scalar.chiptrack.sales.forms.AddNewSalesRepForm" action="/addNewSalesRep.do?action=insertSalesRep" scope="request">


<center><span class="NArialW"><bean:message key="label.sales.salesRep.Name"/></span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>
<table border="0" width="90%" align=right>
 <tr><td>
 <table border="0" width="100%" cellspacing='10' cellpadding='2' align='left'>
<tr><td colspan='2' align=right><a href="javascript:closeWindow(document.addNewSalesRepForm);" onMouseOver="window.status='Click here to close this window';return true" onmouseout="window.status='';return true"><font class='NArialL'>Close this window</font></a></td></tr>
<tr><td colspan='2' id='errorMessagesId'><chiptrack:errors styleClass='NArialL' /></td></tr>
<tr><td colspan='2' id='infoMessagesId'><chiptrack:info styleClass='NArialL' /></td></tr>


    <!--tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer/gif" height=10></td></tr-->
    <tr><td colspan='2' align="left" class='NArialL'><FONT id="errors" styleClass="NArialL" color='FF0000'></FONT></TD></TR>

	<tr>
        <td colspan='2' nowrap><font class="NArialL">New <bean:message key="label.sales.salesRep.Name"/> :<font color=red>*</font>&nbsp;&nbsp;</font>
            <html:text property="newSalesRep" size="25" maxlength="25" styleClass="txfield"/>
		</td>

    </tr>

	<tr>
        <td colspan='1' nowrap align='center'>
		     <a href="javascript:save()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onMouseOver="window.status='Click  to Add Sales Rep';return true" onmouseout="window.status='';return true" title="Click here to Add Sales Rep"></a>
	    </td>
		<td colspan='1' nowrap align='left'>
		     <a href="javascript:reset()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"  onMouseOver="window.status='Click  to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
	    </td>
    </tr>

  </table>

  </td></tr>
  <!--tr><td><img height=10 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif"></td></tr-->
  <tr><td>

<!-- DISPLAY ALL USERS STARTS HERE -->

<% ArrayList salesReps = (ArrayList) request.getAttribute("salesReps");
	if( salesReps != null && salesReps.size() != 0 ) { %>

   <table border="0" width="100%" bordercolor="#FFFFFF" align=right>
    <tr>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF"><bean:message key="label.sales.salesRep.Name"/></font></font></td>
        <td width="15%" align="center" bgcolor="#993333"><font class="NArialL"><font color="#FFFFFF">Action</font></font></td>
        <td width="15%">&nbsp;</td>
    </tr>


    <logic:iterate id="SalesRep" name="salesReps" type="com.scalar.chiptrack.sales.SalesRep">

	<% int bgcount = 0;%>
    <% bgcount = bgcount + 1; %>
    <tr>
    <td nowrap width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
    <bean:write name="SalesRep" property="salesRep" /></font></td>
    <td nowrap width="15%" align="left" <%if(bgcount%2==0){%> bgcolor='#DEE1E2' <% } else {%> bgcolor='#FFFFEE' <%}%>><font class="NArialL">
     <logic:equal name="SalesRep" property="disabled" value="true">
     <a href='<%=chipTracContext%>/addNewSalesRep.do?salesRepstatus=disable&salesRep=<bean:write name="SalesRep" property="encodeSalesRep" />&customerId=<%=request.getParameter("customerId")%>' onMouseOver="window.status='Click to Disable Sales Rep';return true" onmouseout="window.status='';return true">Disable</a>
     </logic:equal>
     <logic:equal name="SalesRep" property="disabled" value="false">
     <a href='<%=chipTracContext%>/addNewSalesRep.do?salesRepstatus=activate&salesRep=<bean:write name="SalesRep" property="encodeSalesRep" />&customerId=<%=request.getParameter("customerId")%>'><font color='red'onMouseOver="window.status='Click to Activate Sales Rep';return true" onmouseout="window.status='';return true"> Activate</font></a>
     </logic:equal>
     </font></td>

    </tr>


    </logic:iterate>
    <tr><td class="NArialL" colspan=5><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=50></td></tr>
    <tr><td colspan=3 align=center><a href="javascript:closeWindow(document.addNewSalesRepForm);" onMouseOver="window.status='Click here to close this window';return true"onmouseout="window.status='';return true"><font class='NArialL'>Close this window</font></a></td></tr>

    </table>
	<% } %>

<!-- DISPLAY ALL USERS ENDS HERE -->

</td></tr>
</table>
<input type="hidden" name="customerId" value ='<%=request.getParameter("customerId")%>' >
</html:form>



</body>

</html:html>